# coding:utf-8
import redis


class Config(object):
    '''配置信息'''

    SECRET_KEY = "kye"
    # 数据库
    SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@172.20.101.110/kyekq"

    # 开启自动提交选项
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # 数据库跟踪修改，默认关闭
    # SQLALCHEMY_TRACK_MODIFICATION = False

    # redis
    REDIS_HOST = "172.20.101.110"
    REDIS_PORT = 6379

    # flask-session配置
    SESSION_TYPE = "redis"
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True  # 对cookie中session_id进行隐藏
    PERMANENT_SESSION_LIFETIME = 86400  # session数据的有效期,单位:秒


class DevelopmentConfig(Config):
    '''开发模式的配置信息'''
    DEBUG = True


class ProductionConfig(Config):
    '''生产环境配置信息'''
    pass


# 构建名字与类的对应关系
config_map = {
    "develop": DevelopmentConfig,
    "product": ProductionConfig
}
